<?php

class CommonHelper {

    public static function isOnline($userId) {
	$lastOnline = db()->createCommand()
		->select('last_online')
		->from('{{users}}')
		->where('user_id = :id', array(
		    ':id' => $userId
		))
		->queryScalar();

	if ($lastOnline) {
	    //neu user thuc hien hanh dong j do trong vong 5' truoc thi online
	    if (time() - $lastOnline < 300) {
		return true;
	    }
	}

	return false;
    }

}

